import Home from '@/pages/Home'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
import Search from '@/pages/Search'
import Test from '@/pages/Test'
// 路由懒加载
const Detail =()=> import('@/pages/Detail');
const AddCartSuccess = ()=> import("@/pages/AddCartSuccess");
const ShopCart = ()=> import("@/pages/ShopCart");
const Trade = ()=> import("@/pages/Trade");
const Pay = ()=> import("@/pages/Pay");
const PaySuccess = ()=> import("@/pages/PaySuccess");
const Center = ()=> import("@/pages/Center");
// import Detail from '@/pages/Detail'
// import AddCartSuccess from "@/pages/AddCartSuccess"
// import ShopCart from '@/pages/ShopCart'
// import Trade from '@/pages/Trade'
// import Pay from '@/pages/Pay'
// import PaySuccess from '@/pages/PaySuccess'
// import Center from '@/pages/Center'
export default [
    {
        path:'/',
        component:Home
    },
    {
        path:'/login',
        component:Login,
        meta:{
            isShow:true
        }
    },
    {
        path:'/register',
        component:Register,
        meta:{
            isShow:true
        }
    },
    {
        path:'/search',
        component:Search
    },
    {
        path:'/test',
        component:Test
    },
    {
        path:'/detail/:id',
        component:Detail
    },
    {
        path:'/addcart_success',
        component:AddCartSuccess,
        beforeEnter:(to,from,next)=>{
            if(from.path.slice(0,7)=== '/detail'){
                next()
            }else{
                next('/')
            }
        }
    },
    {
        path:'/shopcart',
        component:ShopCart
    },
    {
        path:'/trade',
        component:Trade
    },
    {
        path:'/pay',
        component:Pay,
        
    },
    {
        path:'/paysuccess',
        component:PaySuccess,
        beforeEnter: (to, from, next) => {
            if(from.path === '/pay'){
                next()
            }else{
                next('/')
            }
        }
    },
    {
        path:'/center',
        component:Center
    }
]